<?php

class Zhishidi_Question_Block_Adminhtml_Question_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {

    protected function _prepareForm() {
        $form = new Varien_Data_Form();
        $this->setForm($form);
        $fieldset = $form->addFieldset('question_fieldset', array('legend' => Mage::helper('zhishidi_question')->__("Question")));

        $fieldset->addField('name', 'label', array(
            'name' => 'name',
            'label' => Mage::helper('zhishidi_question')->__('Name'),
            'title' => Mage::helper('zhishidi_question')->__('Name'),            
        ));

        $fieldset->addField('email', 'label', array(
            'name' => 'email',
            'label' => Mage::helper('zhishidi_question')->__('Email'),
            'title' => Mage::helper('zhishidi_question')->__('Email'),
        ));

        $fieldset->addField('product', 'label', array(
            'name' => 'product',
            'label' => Mage::helper('zhishidi_question')->__('Product'),
            'title' => Mage::helper('zhishidi_question')->__('Product'),
            'readonly' => true,
        ));

        $fieldset->addField('store_name', 'label', array(
            'name' => 'store_name',
            'label' => Mage::helper('zhishidi_question')->__('Store'),
            'title' => Mage::helper('zhishidi_question')->__('Store'),
        ));

        $dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);        
        $fieldset->addField('created_on', 'label', array(
            'name' => 'created_on',
            'title' => Mage::helper('zhishidi_question')->__("Added Date"),
            'label' => Mage::helper('zhishidi_question')->__("Added Date"),       
            'format' => $dateFormatIso,
            'readonly' => true,
        )); 

         $fieldset->addField('ip', 'label', array(
            'name' => 'ip',
            'label' => Mage::helper('zhishidi_question')->__('IP Address'),
            'title' => Mage::helper('zhishidi_question')->__('IP Address'),
        ));


        $fieldset->addField('question', 'textarea', array(
            'name' => 'question',
            'label' => Mage::helper('zhishidi_question')->__('Question'),
            'title' => Mage::helper('zhishidi_question')->__('Question'),
            'readonly' => true,
        ));

        $fieldset->addField('status', 'select', array(
            'name' => 'status',
            'label' => Mage::helper('zhishidi_question')->__('Status'),
            'title' => Mage::helper('zhishidi_question')->__('Status'),
            'required' => true,
            'class'     => 'required-entry',
            'values' => array(
                array(
                    'value' => 'public',
                    'label' => Mage::helper('zhishidi_question')->__('Public'),
                ),
                array(
                    'value' => 'hidden',
                    'label' => Mage::helper('zhishidi_question')->__('Hidden'),
                )
            ),
        ));



        $fieldset = $form->addFieldset('answer_fieldset', array('legend' => Mage::helper('zhishidi_question')->__("Answer")));
        $fieldset->addField('answer', 'editor', array(
            'name' => 'answer',
            'label' => Mage::helper('zhishidi_question')->__('Answer'),
            'title' => Mage::helper('zhishidi_question')->__('Answer'),
            'require' => true,
            'wysiwyg' => true,
            'class'   => 'required-entry',
            'config'  => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
            
        ));

        if (Mage::getSingleton('adminhtml/session')->getQuestionData()) {
            $form->setValues(Mage::getSingleton('adminhtml/session')->getQuestionData());
            Mage::getSingleton('adminhtml/session')->setQuestionData(null);
        } elseif (Mage::registry('zhishidi_question_data')) {
            $form->setValues(Mage::registry('zhishidi_question_data')->getData());
        }
        return parent::_prepareForm();
    }

}